// +----------------------------------------------------------------------
// | 二手车api请求
// +----------------------------------------------------------------------

import request from "@/utils/request.js";

/**
 * 二手车模块的API
 *
 */


/**
 * 车源详情
 */
export function getUsedCarDetails(id, users_id, city) {
	console.log("打印车源详情请求参数 id " + id + ' users_id  ' + users_id + ' city ' + city)
	return request.get('cars/usedCarDetails?id=' + id + '&users_id=' + users_id + '&city=' + city);

}



/** 
 * 车源列表
 */

export function getUsedCarList(data) {
	return request.get('cars/usedCarList', data);

}

/**
 * 收藏
 * @param data object
 */
export function collectionUpdate(data) {
	return request.post("users/collectionUpdate", data);
}


/**
 * 收藏列表
 * @param data object
 */
export function collectionList(users_id, page_num, page) {
	return request.get("users/collectionList?users_id=" + users_id + '&page_num=' + page_num + '&page=' + page, {}, {
		noAuth: true
	});
}



//二手车模块 基础API



/**
 * 举例get请求
 * 获取热门品牌
 */
export function getHotBrand() {
	return request.get('cars/hotBrand');
}



/**
 * 获取金额条件
 */
export function getPriceWhere() {
	return request.get('cars/priceWhere');
}

/**
 * 获取燃油条件
 */
export function getFuelTypeWhere() {
	return request.get('cars/fuelTypeWhere');
}

/**
 * 车辆颜色
 * @param {String} car_color_state 数据类型 1：外观 2：内饰
 */
export function getVehicleColor(car_color_state) {
	return request.get('cars/vehicleColor?car_color_state=' + car_color_state);
}

/**
 * 车辆性质
 */
export function getNatureUse() {
	return request.get('cars/natureUse');
}

/**
 * 车辆来源
 */
export function getCarOwnerSource() {
	return request.get('cars/carOwnerSource');
}

/**
 * 排放标准
 */
export function getEmissionStandard() {
	return request.get('cars/emissionStandard');
}

/**
 * 车身结构
 */
export function getBodyStructure() {
	return request.get('cars/bodyStructure');
}

/**
 * 燃油类型
 */
export function getFuelType() {
	return request.get('cars/fuelType');
}

/**
 * 我的车源列表数据
 */
export function usedCarMyList(users_id, cars_status, page_num, page, model_two_id) {
	return request.get('cars/usedCarMyList?users_id=' + users_id + '&cars_status=' + cars_status + '&page_num=' +
		page_num + '&page=' + page + '&model_two_id=' + model_two_id);
}


/**
 * 删除我的车源 
 * @param data object 车源主键 id
 * {"id":"7FC89D2E-44E0-518F-8DF5-41AE5D5CDA8B"}
 */
export function deleteMeCarSource(data) {
	console.log("打印删除我的已下架的车源的数据 " + JSON.stringify(data))
	return request.post("cars/usedCarDelete", data);
}

/**
 * 上架（发布）我的车源 
 * @param data object 车源主键 id
 */
export function upMeCarSource(data) {
	console.log("打印上架请求的参数" + JSON.stringify(data))
	return request.post("cars/usedCarAdd", data);
}

/**
 * 下架我的车源 
 * @param data object 车源主键 id
 */
export function usedCarOffShelf(data) {
	return request.post("cars/usedCarOffShelf", data);
}

/**
 * 编辑我的车源 
 * @param data object 车源主键 id
 */
export function usedCarEdit(data) {
	return request.post("cars/usedCarEdit", data);
}

/**
 * 编辑我的车源详情 
 * @param data object 车源主键 id
 */
export function usedCarEditDetails(cars_id) {
	console.log("cars/usedCarEditDetails?id=" + cars_id)
	return request.get("cars/usedCarEditDetails?id=" + cars_id, {});
}



/**
 * 根据条件获取车源列表
 * /**
 *	postData: {
 *		page: 1, //第几页数据
 *		page_num: 10, // 行数 必传 其他都是非必须
 *		order: 0, // 排序0：默认排序 1：最新上架 2：价格最低 3：价格最高 4：里程最少 5：车龄最短
 *		brand_id: '', //品牌id
 *		series_id: '', //二级车系id
 *		start_price: '', // 价格起 
 *		end_price: '', // 价格止
 *		start_car_age: '', // //车龄起  
 *		end_car_age: '', // 车龄止
 *		where_city_id: '', // 车辆所在地市id
 *		registration_city_id: '', // 上牌地市id
 *		structure_id: '', // 车身结构id
 *		standard_id: '', // 排放标准id
 *		fuel_type_id: '', // 燃油类型id
 *		users_id: '', //用户id
 *		search: '' //搜索框输入的内容
 *}
 */
export function getSecondhandCarList(data) {
	return request.get('cars/usedCarList?page=' + data.page + '&page_num=' + data.page_num + '&order=' + data.order +
		'&series_id=' +
		data.series_id +
		'&start_price=' + data.start_price + '&end_price=' + data.end_price + '&start_car_age=' + data
		.start_car_age +
		'&end_car_age=' + data.end_car_age + '&where_city_id=' + data.where_city_id + '&registration_city_id=' +
		data.registration_city_id + '&structure_id=' + data.structure_id + '&standard_id=' + data.standard_id +
		'&fuel_type_id=' +
		data.fuel_type_id + '&users_id=' + data.users_id + '&search=' + data.search
	);
}



/**
 * 寻车模块的API
 *
 */
/**
 * 二手车寻车列表
 */
export function getCarSearchReleaseList(page_num, series_id, source_type_id, registration_province, sreach, page) {
	console.log('cars/usedCarSearchReleaseList?page_num=' + page_num + '&series_id=' + series_id +
		'&source_type_id=' + source_type_id + '&registration_province=' + registration_province + '&sreach=' +
		sreach)
	return request.get('cars/usedCarSearchReleaseList?page_num=' + page_num + '&series_id=' + series_id +
		'&source_type_id=' + source_type_id + '&registration_province=' + registration_province + '&sreach=' +
		sreach + '&page=' + page, {}, {
			noAuth: true
		});
}

/**
 * 寻车列表车源类型
 */
export function usedCarSearchCarSourceType() {
	return request.get('cars/usedCarSearchCarSourceType', {}, {
		noAuth: true
	});
}
/**
 * 寻车列表按省进行搜索
 */
export function usedCarSearchProvince() {
	return request.get('cars/usedCarSearchProvince', {}, {
		noAuth: true
	});
}

/**
 * 寻车列表按品牌
 */
export function usedCarSearchBrand() {
	return request.get('cars/usedCarSearchBrand', {}, {
		noAuth: true
	});
}

/**
 * 寻车列表按车系搜索
 */
export function usedCarSearchSeries(brand_id) {
	return request.get('cars/usedCarSearchSeries?brand_id=' + brand_id, {}, {
		noAuth: true
	});
}


/**
 * 举例post请求
 * 
 * @param data object 用户手机号
 */
export function registerVerify(data) {
	return request.post("register/verify", data, {
		noAuth: true
	});
}



//二手车模块获取数据列表API
/**
 * 获取推荐车源列表
 */
export function getRecommendCarList(page_num, page, where_city_id, sreach) {
	console.log("page_num    " + page_num + "     page     " + page + "   sreach   " + sreach)
	return request.get('cars/usedCarList?page_num=' + page_num + '&page=' + page +
		'&order=&series_id=&start_price=&end_price=&start_car_age=&end_car_age=&where_city_id=' + where_city_id +
		'&registration_city_id=&structure_id=&standard_id=&fuel_type_id=&search=' + sreach, {}, {
			noAuth: true
		});
}


/**
 * 二手车寻车详情
 * @param {Object} data
 */

export function getSearchCarDetail(data) {
	return request.get("cars/usedCarSearchReleaseDetails", data, {
		noAuth: true
	});
}


// usedCarSearchModelsHave

/**
 * 寻车报价车型是否拥有
 */

export function isCarSearchModelsHave(data) {
	return request.get("cars/usedCarSearchModelsHave", data, {
		noAuth: true
	});
}


// cars/usedSearchReturnModels

/**
 * 根据车型id返回车型
 */

export function getCardModelInfo(data) {
	return request.get("cars/usedSearchReturnModels", data, {
		noAuth: true
	});
}

/**
 * 报价联系人列表
 */

export function getContactList(userid) {
	return request.get("cars/quotationContactList?users_id=" + userid, {
		noAuth: true
	});
}

/**
 * 添加报价联系人
 */

export function addConnect(data) {
	return request.post("cars/quotationContactAdd", data, {
		noAuth: true
	});
}

/**
 * 删除报价联系人
 */

export function deleteConnect(data) {
	return request.post("cars/quotationContactDelete", data, {
		noAuth: true
	});
}


/**
 * 添加报价
 * @param {Object} data
 */

export function addQuotation(data) {
	return request.post("cars/usedCarSearchQuotationAdd", data, {
		noAuth: true
	});
}

/**
 * 查询报价
 * @param {Object} data
 */

export function getQuotation(data) {
	return request.get("cars/usedCarSearchQuotationView", data, {
		noAuth: true
	});
}


/**
 * 修改报价
 * @param {Object} data
 */

export function updateQuotation(data) {
	return request.post("cars/usedCarSearchQuotationUpdate", data, {
		noAuth: true
	});
}

/**
 * 取消报价
 * @param {Object} data
 */

export function cancelQuotation(data) {
	return request.post("cars/usedCarSearchQuotationCancel", data, {
		noAuth: true
	});
}


/**
 * 查询自提距离
 */

export function getDistance(data) {
	return request.get("cars/usedSearchDistance", data, {
		noAuth: true
	});
}

/**
 * 查询店保
 */

export function getSituation(data) {
	return request.get("cars/usedSearchSituation", data, {
		noAuth: true
	});
}



/**
 * usedCarSearchQuotationList
 * 获取报价列表
 * 
 */

export function getQuotationList(data) {
	return request.get("cars/usedCarSearchQuotationList", data, {
		noAuth: true
	});
}

/**
 * usedCarSearchQuotationList
 * 获取报价详情
 * 
 */

export function getQuotationDetail(data) {
	return request.get("cars/usedCarSearchQuotationDetails", data, {
		noAuth: true
	});
}